package cvsexercise3;

public class DoubleSelection {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		/* Write out a start message to the console */
		System.out.println("Exercise 3 - Double Selection started");
		
		/* Create and initialize two String variables
		 * similar to str1 and str3 in Equality Operator exercise
		 */
		String str1 = new String("HelloWorld");
		String str2 = new String("HelloJavaWorld");
		
		/* Output the String variables */
		System.out.println("String str1 = " + str1);
		System.out.println("String str2 = " + str2);
		
		/* Output the length of each string 
		 * NOTE: use the String class length() method 
		 */
		System.out.println("Length of str1 = " + str1.length());
		System.out.println("Length of str2 = " + str2.length());
		
		/* Output the fifth character of each string
		 * NOTE: use the  String class charAt() method  
		 */
		char str1CharVal = ' ';
		char str2CharVal = ' ';
		str1CharVal = str1.charAt(5);
		System.out.println("Character at index 5 of str1 = " + str1CharVal);
		str2CharVal = str2.charAt(5);
		System.out.println("Character at index 5 of str2 = " + str2CharVal);
		
		/* Test if the two characters are the same and write out a result message */
		if (str1CharVal == str2CharVal) {
			System.out.println("Both characters are the same!");
		} else {
			System.out.println("Both characters are different!");
		}
		
		/* Determine which string contains the word Java and write out a result message
		 * NOTE: Use the String class contains() method 
		 */
		if (str1.contains("Java")) {
			System.out.println("str1 contains the word Java!");
		} else {
			System.out.println("str2 contains the word Java!");
		}
		
		/* Write out a completed message to the console */
		System.out.println("Exercise 3 - Double Selection completed");
	}
}
